#include <stdio.h>
typedef struct {
    int id;
    char name[50];
    char gender;
    float chinese;
    float math;
    float english;
    float average;
} Student;

void sort(Student *students,int size){
    for (int i=0;i<size;i++){
        for (int j=size-1;j>0;j--){
            if (students[j-1].average < students[j].average){
                Student temp = students[j-1];
                students[j-1] = students[j];
                students[j] = temp;
            }
        }
    }
}

void main(){
    Student students[5];

    for (int i = 0; i < 5; i++) {
        scanf("%d %s %c %f %f %f", &students[i].id, students[i].name, &students[i].gender, &students[i].chinese, &students[i].math, &students[i].english);
    }
    for (int i = 0; i < 5;i++){
        students[i].average = (students[i].chinese + students[i].math + students[i].english) / 3.0;
    }
    
    float num1, num2, num3;
    num1 = (students[0].chinese + students[1].chinese + students[2].chinese + students[3].chinese + students[4].chinese) / 5.0;
    num2 = (students[0].math + students[1].math + students[2].math + students[3].math + students[4].math) / 5.0;
    num3 = (students[0].english + students[1].english + students[2].english + students[3].english + students[4].english) / 5.0;
    
    

    for (int i = 0; i < 5; i++) {
        printf("Student %d Average: %.2f\n", students[i].id, students[i].average);
    }
    printf("Chinese Average: %.2f\n", num1);
    printf("Math Average: %.2f\n", num2);
    printf("English Average: %.2f\n", num3);
    
    sort(students,5);
    for (int i = 0; i < 5; i++) {
        printf("Rank %d: Student %d\n", i + 1, students[i].id);
    }



}